package Windows;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.Rectangle;

import javax.swing.JProgressBar;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

/**
 * Dimension FOR JProgressBar 单元格进度条渲染器
 * 
 * @author 紫夜
 * 
 */
public class RatioRenderer extends JProgressBar implements TableCellRenderer {
	@Override
	public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
		final Dimension pair = (Dimension) value;
		setMinimum(0);
		setMaximum(pair.height);
		setValue(pair.width);

		if (isSelected)
			setBackground(table.getSelectionBackground());
		else
			setBackground(table.getBackground());
		return this;
	}

	@Override
	public boolean isOpaque() {
		return true;
	}

	@Override
	public void repaint(long tm, int x, int y, int width, int height) {
	}

	@Override
	public void repaint(Rectangle r) {
	}

	@Override
	public void revalidate() {
	}

	@Override
	public void validate() {
	}
}